﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using wrsm.common.exceptions;

namespace wrsm.common.net {

    /// <summary>
    /// Used to make web requests
    /// </summary>
    [CLSCompliant(true)]
    public class WebRequest {

        private WebClient _client = new WebClient();

        private object _clientLock = new object();

        /// <summary>
        /// Simple HTTP get
        /// </summary>
        /// <param name="url">url to download from</param>
        /// <returns>http response</returns>
        public string GetHttp(string url) {
            lock (_clientLock) {
                try {
                    return _client.DownloadString(url);
                } catch (Exception caught) {
                    throw new WrsmNetworkException("Unable to make web request", caught);
                }
            }
        }

    }
}
